<template>
    <h3>添加操作人员</h3>
    <el-form :model="Operator" label-width="120px">
        <el-form-item label="姓名">
            <el-input v-model="Operator.adminname" />
        </el-form-item>
        <el-form-item label="密码">
            <el-input type="password" v-model="Operator.password" />
        </el-form-item>
        <el-form-item label="角色">
            <!-- <el-input v-model="Operator.role" /> -->
            <el-radio-group v-model="Operator.role">
                <el-radio :label="3">超级管理员</el-radio>
                <el-radio :label="6">普通管理员</el-radio>
            </el-radio-group>
        </el-form-item>
        <el-form-item>
            <el-button :plain="true" @click="onSubmit">上传</el-button>
            <!-- <el-button type="primary" @click="onSubmit">上传</el-button> -->
            <!-- <el-button>取消</el-button> -->
        </el-form-item>
    </el-form>
</template>
<script setup lang="ts">
import { ElMessage } from 'element-plus';
import 'element-plus/dist/index.css';
import { reactive } from 'vue'
import { useRouter } from "vue-router"
import service from '../../../utils/service';
// 使用userRouter() 得到路由对象。
const router = useRouter();
const Operator = reactive({
    adminname: "",
    password: "",
    role: 1,
    checkedKeys: []
})
const onSubmit = () => {
    if (Operator != null) {
        service({
            url: "/admin/add",
            method: "post",
            data: Operator
        }).then(res => {
            if (res.data.code == 200) {
                // alert("已添加")
                ElMessage({
                    message: '恭喜您，亲，您的文件上传成功',
                    type: 'success',
                })
                // 跳转到操作员列表
                router.push("/Admin/OperatorList");
            }
        })
    }
}
</script>
<style scoped>
.el-button {
    background-color: green;
    color: white;
}
.el-input{
    width: 300px;
}
</style>
